package com.zeny.coding.dto;


import com.zeny.coding.constants.CourseConstants;
import com.zeny.coding.util.DtoUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import javax.xml.bind.ValidationException;

/**
 * <h2>排序</h2>
 *
 * @Author Zeny
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class SortDto {
    private String courseId;
    private Integer oldSort;
    private Integer newSort;

    public void valid() throws ValidationException {
        DtoUtil.valid(this.courseId, true, 1, 19);
        DtoUtil.require(oldSort);
        DtoUtil.require(newSort);
        if (oldSort.equals(newSort)) {
            throw new ValidationException(CourseConstants.REQUEST_PARAMS_ERROR);
        }
    }
}
